Skip to content

Add text localization capabilities to pagination component - #1391

Merged
rezrah merged 3 commits into
mainfrom
rezrah/l10n-pagination-labels
Jul 15, 2026
Merged

Add text localization capabilities to pagination component#1391
rezrah merged 3 commits into
mainfrom
rezrah/l10n-pagination-labels

Conversation

@rezrah

@rezrah rezrah commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

Resolves #1249

Adds customizable prev/next text labels to the Pagination component. Previously they were hard-coded.
The Pagination component doesn't currently use the compound component API pattern, so adding a named child here felt like an overreach. It's currently modelled after its product counterpart component, where it's an entirely prop-based API.

🔗 Preview

List of notable changes:

  • added a label prop which accepts a strongly typed object
  • added stories, tests and docs

What should reviewers focus on?

  • How do you feel about the labels prop, any better alternatives?

Steps to test:

  1. See this example

Supporting resources (related issues, external links, etc):

Contributor checklist:

  • All new and existing CI checks pass
  • Tests prove that the feature works and covers both happy and unhappy paths
  • Any drop in coverage, breaking changes or regressions have been documented above
  • UI Changes contain new visual snapshots (generated by adding update snapshots label to the PR)
  • All developer debugging and non-functional logging has been removed
  • Related issues have been referenced in the PR description

Reviewer checklist:

  • Check that pull request and proposed changes adhere to our contribution guidelines and code of conduct
  • Check that tests prove the feature works and covers both happy and unhappy paths
  • Check that there aren't other open Pull Requests for the same update/change

Screenshots:

Screenshot 2026-07-07 at 13 07 47

@rezrah
rezrah requested a review from a team as a code owner July 7, 2026 12:45
Copilot AI review requested due to automatic review settings July 7, 2026 12:45
@changeset-bot

changeset-bot Bot commented Jul 7, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 05818ca

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
@primer/react-brand Patch
@primer/brand-docs Patch
@primer/brand-css Patch
@primer/brand-primitives Patch
@primer/brand-e2e Patch
@primer/brand-fonts Patch
@primer/brand-mcp Patch
@primer/brand-config Patch
@primer/brand-storybook Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

🟢 No design token changes found

@rezrah
rezrah temporarily deployed to github-pages July 7, 2026 12:48 — with GitHub Actions Inactive

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds localization support to @primer/react-brand’s Pagination component by making the visible Previous/Next control text configurable via a new labels prop (resolving #1249), and updates surrounding documentation and test coverage.

Changes:

  • Added labels?: {prev?: string; next?: string} to Pagination and threaded labels into item rendering.
  • Added/updated Storybook feature story + Playwright visual snapshot to cover custom labels.
  • Added unit tests, docs, and a changeset entry documenting the new API.
Show a summary per file
File Description
packages/react/src/Pagination/Pagination.tsx Adds labels prop and uses it to render customizable prev/next visible text.
packages/react/src/Pagination/Pagination.test.tsx Adds unit tests for custom labels and default fallback behavior.
packages/react/src/Pagination/Pagination.features.stories.tsx Adds Storybook feature story demonstrating localized labels.
packages/react/src/Pagination/Pagination.visual.spec.ts Adds visual regression coverage for the custom labels story.
apps/next-docs/content/components/Pagination/index.mdx Documents the new labels prop and provides a live example.
.changeset/pagination-labels-prop.md Announces the new labels prop in release notes.

Review details

  • Files reviewed: 6/7 changed files
  • Comments generated: 4
  • Review effort level: Low

Comment thread packages/react/src/Pagination/Pagination.tsx Outdated
Comment thread packages/react/src/Pagination/Pagination.tsx
Comment thread apps/next-docs/content/components/Pagination/index.mdx Outdated
Comment thread .changeset/pagination-labels-prop.md Outdated
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

🟢 Bundle size report

CheckMainBranchChange
UMD — full bundle (JS)101.33 kB101.36 kB⬆️ +36 B (+0.0%)
UMD — full bundle (CSS)66.82 kB66.82 kB🟢 No change
ESM — full bundle (JS + CSS)1.51 MB1.51 MB⬆️ +182 B (+0.0%)
ESM — tree-shaken simple (Button)69.70 kB69.70 kB🟢 No change
ESM — tree-shaken complex (ActionMenu)78.48 kB78.48 kB🟢 No change

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

🟢 No visual differences found

Our visual comparison tests did not find any differences in the UI.

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

🟢 Unit test coverage changes found

Unit test coverage has been updated through this PR.

Changes: 0 new tests, 0 removed tests, 1 improved, 0 decreased

Component/Hook Statements Functions Branches Change
Pagination 85.0% 86.7% 73.3% 94.7% 95.7% +1.7%

@rezrah
rezrah temporarily deployed to github-pages July 7, 2026 13:05 — with GitHub Actions Inactive
@rezrah
rezrah requested a review from danielguillan July 8, 2026 10:02
@rezrah
rezrah temporarily deployed to github-pages July 8, 2026 10:05 — with GitHub Actions Inactive

@danielguillan danielguillan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@rezrah
rezrah merged commit 930ab18 into main Jul 15, 2026
17 checks passed
@rezrah
rezrah deleted the rezrah/l10n-pagination-labels branch July 15, 2026 13:22
@primer primer Bot mentioned this pull request Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pagination component hard codes localization values for 'Next' and 'Previous'

3 participants